require.config({
  baseUrl: "app",
  paths: {
    // "constants": "constants",
    "framework7": "https://cdn.bootcss.com/framework7/1.6.4/js/framework7.min",
    "jquery": "https://cdn.bootcss.com/jquery/3.2.1/jquery.min",
    "cookie": "https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min",
    "moment": "https://cdn.bootcss.com/moment.js/2.18.1/moment.min",
    "lodash": "http://cdn.bootcss.com/lodash.js/4.17.2/lodash.min",
    "moment": "https://cdn.bootcss.com/moment.js/2.18.1/moment.min",
    "dates": "services/dates",
    "template7compile": "services/template7compile",
    "apiClient": "services/api-client",
    "alert": "services/alert",
    /* student side */
    "index": "features/student_side/index",
    "schedule": "features/student_side/schedule/index",
    "course": "features/student_side/course/detail",
  },
  shim: {
    "moment": {
      exports: "moment"
    },
    "lodash": {
      exports: "_"
    },
    "jquery": {
      exports: "$"
    },
    'framework7': {
      exports: 'Framework7'
    }
  }
});

require([
  'framework7',
  'jquery',
  'lodash',
  'moment',
  'apiClient',
  'alert',
  'index',
  'schedule',
  'course',
], function(f7, $, _, moment, apiClient, alert, index, schedule, course) {
  // Initialize your app
  window.app = new f7({init: false, modalButtonOk: "确定", pushState: true, modalButtonCancel: "取消", pushStateSeparator: "#!"})
  // Export selectors engine
  window.$$ = Dom7;
  // Add view
  window.mainView = app.addView('.view-main', {
    // Because we use fixed-through navbar we can enable dynamic navbar
    //dynamicNavbar: true
  });
  window.Template7 = Template7;
  /*
   * 页面初始化前回调函数
   */
  $$(document).on('pageBeforeInit', function(e) {
    var pageObj = eval(e.detail.page.name);
    if (pageObj['beforeInit']) {
      pageObj.beforeInit(e);
    }
  });
  /*
   * 页面初始化时回调函数
   */
  $$(document).on('pageInit', function(e) {
    var pageObj = eval(e.detail.page.name);
    if (pageObj['init']) {
      pageObj.init(e);
    }
  });

  /*
   * 页面跳转动画前回调函数
   */
  $$(document).on('pageBeforeAnimation', function(e) {
    var pageObj = eval(e.detail.page.name);
    if (pageObj['beforeAnime']) {
      pageObj.beforeAnime(e);
    }
  });
  /*
   * 页面跳转动画后回调函数
   */
  $$(document).on('pageAfterAnimation', function(e) {
    var pageObj = eval(e.detail.page.name);
    if (pageObj['afterAnime']) {
      pageObj.afterAnime(e);
    }
  });

  app.init();
})
